#include "linux/platform_device.h"
#include "linux/of_platform.h"
#include "linux/printk.h"

int of_device_add(struct platform_device *ofdev)
{
    int i;;

    printk("\nadd platform device: %s\n", ofdev->name ? ofdev->name : ofdev->dev.init_name);
    printk("  id: %d\n", ofdev->id);
    printk("  num_resources: %d\n", ofdev->num_resources);
    for (i = 0; i < ofdev->num_resources; i++)
    {
        printk("  resource[%d]:%s flag: %lx start=0x%lx, end=0x%lx\n", i, ofdev->resource[i].name,
               ofdev->resource[i].flags, ofdev->resource[i].start, ofdev->resource[i].end);
    }
    printk("\n");

    ofdev->name = dev_name(&ofdev->dev);

    return device_add(&ofdev->dev);
}

struct of_device_id *of_match_device(struct of_device_id *matches, struct device *dev)
{
	if ((!matches) || (!dev->of_node))
		return NULL;
	return of_match_node(matches, dev->of_node);
}

int of_driver_match_device(struct device *dev, struct device_driver *drv)
{
	return of_match_device(drv->of_match_table, dev) != NULL;
}